From: vhanquez@gwig.uk.xensource.com Date: Mon, 31 Jul 2006 09:30:36 +0000 (+0000) Subject: Add a transaction_started field in xenstored connection structure instead of X-Git-Tag: archive/raspbian/4.8.0-1+rpi1~1^2~15754^2~40 X-Git-Url: https://dgit.raspbian.org/%22http:/www.example.com/cgi/%22https:/%22bookmarks://%22Dat/%22http:/www.example.com/cgi/%22https:/%22bookmarks:/%22Dat?a=commitdiff_plain;h=8d79f14a5d89af02c8a9dd3710228c4d7c20b237;p=xen.git Add a transaction_started field in xenstored connection structure instead of browsing the list of transaction each time Bump the default to 10, and make it configurable through the command line. Signed-off-by: Vincent Hanquez --- diff --git a/tools/xenstore/xenstored_core.c b/tools/xenstore/xenstored_core.c index 25330f9906..2511e4a5fc 100644 --- a/tools/xenstore/xenstored_core.c +++ b/tools/xenstore/xenstored_core.c @@ -80,6 +80,7 @@ static void check_store(void); int quota_nb_entry_per_domain = 1000; int quota_nb_watch_per_domain = 128; int quota_max_entry_size = 2048; /* 2K */ +int quota_max_transaction = 10; #ifdef TESTING static bool failtest = false; @@ -1342,6 +1343,7 @@ struct connection *new_connection(connwritefn_t *write, connreadfn_t *read) new->write = write; new->read = read; new->can_write = true; + new->transaction_started = 0; INIT_LIST_HEAD(&new->out_list); INIT_LIST_HEAD(&new->watches); INIT_LIST_HEAD(&new->transaction_list); @@ -1739,6 +1741,7 @@ static void usage(void) " --entry-nb limit the number of entries per domain,\n" " --entry-size limit the size of entry per domain, and\n" " --entry-watch limit the number of watches per domain,\n" +" --transaction limit the number of transaction allowed per domain,\n" " --no-recovery to request that no recovery should be attempted when\n" " the store is corrupted (debug only),\n" " --preserve-local to request that /local is preserved on start-up,\n" @@ -1755,6 +1758,7 @@ static struct option options[] = { { "output-pid", 0, NULL, 'P' }, { "entry-size", 1, NULL, 'S' }, { "trace-file", 1, NULL, 'T' }, + { "transaction", 1, NULL, 't' }, { "no-recovery", 0, NULL, 'R' }, { "preserve-local", 0, NULL, 'L' }, { "verbose", 0, NULL, 'V' }, @@ -1774,7 +1778,7 @@ int main(int argc, char *argv[]) const char *pidfile = NULL; int evtchn_fd = -1; - while ((opt = getopt_long(argc, argv, "DE:F:HNPS:T:RLVW:", options, + while ((opt = getopt_long(argc, argv, "DE:F:HNPS:t:T:RLVW:", options, NULL)) != -1) { switch (opt) { case 'D': @@ -1804,6 +1808,9 @@ int main(int argc, char *argv[]) case 'S': quota_max_entry_size = strtol(optarg, NULL, 10); break; + case 't': + quota_max_transaction = strtol(optarg, NULL, 10); + break; case 'T': tracefile = optarg; break; diff --git a/tools/xenstore/xenstored_core.h b/tools/xenstore/xenstored_core.h index f16d018047..0849e7ba78 100644 --- a/tools/xenstore/xenstored_core.h +++ b/tools/xenstore/xenstored_core.h @@ -79,6 +79,7 @@ struct connection /* List of in-progress transactions. */ struct list_head transaction_list; uint32_t next_transaction_id; + unsigned int transaction_started; /* The domain I'm associated with, if any. */ struct domain *domain; diff --git a/tools/xenstore/xenstored_transaction.c b/tools/xenstore/xenstored_transaction.c index a3f2157256..fb20287f99 100644 --- a/tools/xenstore/xenstored_transaction.c +++ b/tools/xenstore/xenstored_transaction.c @@ -66,6 +66,7 @@ struct transaction struct list_head changes; }; +extern int quota_max_transaction; static unsigned int generation; /* Return tdb context to use for this connection. */ @@ -125,7 +126,6 @@ void do_transaction_start(struct connection *conn, struct buffered_data *in) { struct transaction *trans, *exists; char id_str[20]; - int started; /* We don't support nested transactions. */ if (conn->transaction) { @@ -133,11 +133,7 @@ void do_transaction_start(struct connection *conn, struct buffered_data *in) return; } - started = 0; - list_for_each_entry(trans, &conn->transaction_list, list) - started++; - - if (started > 5) { + if (conn->transaction_started > quota_max_transaction) { send_error(conn, ENOSPC); return; } @@ -166,6 +162,7 @@ void do_transaction_start(struct connection *conn, struct buffered_data *in) list_add_tail(&trans->list, &conn->transaction_list); talloc_steal(conn, trans); talloc_set_destructor(trans, destroy_transaction); + conn->transaction_started++; sprintf(id_str, "%u", trans->id); send_reply(conn, XS_TRANSACTION_START, id_str, strlen(id_str)+1); @@ -188,6 +185,7 @@ void do_transaction_end(struct connection *conn, const char *arg) conn->transaction = NULL; list_del(&trans->list); + conn->transaction_started--; /* Attach transaction to arg for auto-cleanup */ talloc_steal(arg, trans);